package com.community.entity;

import java.util.Date;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import java.io.Serializable;

/**
 * (ParkingInmanage)表实体类
 *
 * @author makejava
 * @since 2021-11-10 09:24:35
 */
@SuppressWarnings("serial")
public class ParkingInmanage extends Model<ParkingInmanage> {

    @TableId(value = "id", type = IdType.INPUT) //这种方式是主键手动输入
    private Long id;
    //车牌号
    private String carNumber;
    //进场时间
    private Date inData;
    //在场时间
    @TableField(exist = false)
    private String onDate;
    //1：在场 1：离场
    private String status;
    //1：临时车 1：固定车
    private String carType;
    //车位
    private String parking;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCarNumber() {
        return carNumber;
    }

    public void setCarNumber(String carNumber) {
        this.carNumber = carNumber;
    }

    public Date getInData() {
        return inData;
    }

    public void setInData(Date inData) {
        this.inData = inData;
    }

    public String getOnDate() {
        try {
            long diff = new Date().getTime() - this.getInData().getTime();//这样得到的差值是毫秒级别
            long days = diff / (1000 * 60 * 60 * 24);
            long hours = (diff - days * (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
            long minutes = (diff - days * (1000 * 60 * 60 * 24) - hours * (1000 * 60 * 60)) / (1000 * 60);
//            System.out.println("" + days + "天" + hours + "小时" + minutes + "分");
            onDate = "" + days + "天" + hours + "小时" + minutes + "分";
        } catch (Exception e) {
            System.out.println(e);
        }
        return onDate;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getCarType() {
        return carType;
    }

    public void setCarType(String carType) {
        this.carType = carType;
    }

    public String getParking() {
        return parking;
    }

    public void setParking(String parking) {
        this.parking = parking;
    }

    /**
     * 获取主键值
     *
     * @return 主键值
     */
    @Override
    protected Serializable pkVal() {
        return this.id;
    }

    @Override
    public String toString() {
        return "ParkingInmanage{" +
                "id=" + id +
                ", carNumber='" + carNumber + '\'' +
                ", inData=" + inData +
//                ", hours='" + hours + '\'' +
                ", status=" + status +
                ", carType=" + carType +
                ", parking='" + parking + '\'' +
                '}';
    }


}

